package com.battleship;

import java.util.Arrays;
import java.util.List;

public class Ship {
    private String name;
    private List<Point> points;
    private int hits;

    public Ship(String name, Point... points) {
        this.name = name;
        this.points = Arrays.asList(points);
    }

    public int guess(Point point) {
        if (points.contains(point)) {
            hits++;
            if (hits == points.size()) {
                return 2;
            } else {
                return 1;
            }
        }
        return 0;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Ship ship = (Ship) o;
        return !(name != null ? !name.equals(ship.name) : ship.name != null);
    }
}
